#include <iostream>
#include<string> 

using namespace std;

//字符串比较

void test06()
{
    string str1 = "hello";
    string str2 = "hello";

    //compar常用于比较两个字符串相等或不相等，判断谁大谁小的意义并不是很大
    if (str1.compare(str2) == 0)
    {
        cout << "str1 等于 str2" << endl;
    }
    else if (str1.compare(str2) > 0)
    {
        cout << "str1 大于 str2" << endl;
    }
    else
    {
        cout << "str1 小于 str2" << endl;
    }


    string str3 = "hello world";
    string str4 = "hello c++";

    if (str3.compare(str4) == 0)
    {
        cout << "str3 等于 str4" << endl;
    }
    else if (str3.compare(str4) > 0)
    {
        cout << "str3 大于 str4" << endl;
    }
    else
    {
        cout << "str3 小于 str4" << endl;
    }
}

int main()
{
    test06();

    return 0;
}
